package view.maze;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;

public class MazeTile extends Canvas 
{
	// Data Members //
	private int value;
	
	
	
	// Tile CTOR //
	public MazeTile(Composite parent, int style)
	{
		// Composite Parent CTOR
		
		
		super(parent,style);
		
		value=0;
		
		
		
	}
		
		
		
	
	// Set the value, change colors accordingly, and redraw
	public void setValue(int value)
	{
		this.value = value;
		changeColors();
		redraw();
	}

	// Change the colors according to this.value
	private void changeColors()
	{
		changeBackgroundColor();
		changeTextColor();
		
	}
	
	// Change the background color
	private void changeBackgroundColor() 
	{
		if(this.value == -1)
			setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
		if(this.value == 2)
			setBackground(getDisplay().getSystemColor(SWT.COLOR_YELLOW));
		if(this.value == 1)
			setBackground(getDisplay().getSystemColor(SWT.COLOR_RED));
		if(this.value == 0)
			setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));
		
		
	}

	// Change the text (foreground) color according to this.value
	private void changeTextColor() 
	{
		setForeground(getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
	}
	
	
}